<template>
  <div class="dimension">
    <div class="container">
      <div class="top">
        <span>维度转换</span>
        <!--地区-->
        <img :src="imgUrl" alt @click="$store.state.noAreadimensionState = false" />
      </div>
      <div class="main">
        <div class="row">
          <div></div>
          <div class="row_main">
            <div :class="{active:colVal==='指标'}" @click="changeTabel('指标','col')">指标</div>
            <div :class="{active:colVal==='时间'}" @click="changeTabel('时间','col')">时间</div>
          </div>
        </div>
        <div class="col">
          <div class="row_main">
            <div :class="{active:rowVal==='指标'}" @click="changeTabel('指标','row')">指标</div>
            <div :class="{active:rowVal==='时间'}" @click="changeTabel('时间','row')">时间</div>
          </div>
          <div class="tabel">
            <div>
              <div>{{rowVal}}</div>
              <div>{{colVal}}</div>
              <div>{{colVal}}</div>
              <div>{{colVal}}</div>
            </div>
            <div>
              <div>{{rowVal}}</div>
              <div></div>
              <div></div>
              <div></div>
            </div>
            <div>
              <div>{{rowVal}}</div>
              <div></div>
              <div></div>
              <div></div>
            </div>
            <div>
              <div>{{rowVal}}</div>
              <div></div>
              <div></div>
              <div></div>
            </div>
          </div>
        </div>
      </div>
      <div class="bottom">
        <div @click="trueChange()">确定</div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'dimension',
  data () {
    return {
      imgUrl: require('../../../static/nav/deleteImg.png'),
      rowVal: '指标',
      colVal: '时间',
      arrValue: {
        '指标': 'zb',
        '时间': 'sj'
      }
    }
  },
  methods: {
    changeTabel (stateSD, strd) {
      if (strd === 'row') {
        this.rowVal = stateSD
      } else if (strd === 'col') {
        this.colVal = stateSD
      }
    },
    // 维度转换默认
    change3D () {
      // if (this.$store.state.transState) {
      console.log(this.$store.state.SelecttDimension, 'this.$store.state.SelecttDimension')
      if (this.$store.state.SelecttDimension.col === 'zb' && this.$store.state.SelecttDimension.row === 'sj') {
        this.rowVal = '指标'
        this.colVal = '时间'
      } else if (this.$store.state.SelecttDimension.col === 'sj' && this.$store.state.SelecttDimension.row === 'zb') {
        this.rowVal = '时间'
        this.colVal = '指标'
      } else if (this.$store.state.SelecttDimension.col === 'dq' && this.$store.state.SelecttDimension.row === 'sj') {
        this.rowVal = '地区'
        this.colVal = '时间'
      } else if (this.$store.state.SelecttDimension.col === 'sj' && this.$store.state.SelecttDimension.row === 'dq') {
        this.rowVal = '时间'
        this.colVal = '地区'
      } else if (this.$store.state.SelecttDimension.col === 'dq' && this.$store.state.SelecttDimension.row === 'zb') {
        this.rowVal = '地区'
        this.colVal = '指标'
      } else if (this.$store.state.SelecttDimension.col === 'zb' && this.$store.state.SelecttDimension.row === 'dq') {
        this.rowVal = '指标'
        this.colVal = '地区'
      }
      // }
    },
    // 确定维度转换
    trueChange () {
      if (this.rowVal === this.colVal) {
        this.$alert('维度转换格式错误！行列相同', '温馨提示', {
          confirmButtonText: '确定'
        })
        // alert('维度转换格式错误！行列相同')
      } else if (this.$store.state.SelecttDimension.col === this.arrValue[this.rowVal]) {
        this.$store.state.noAreadimensionState = false
      } else {
        // 告诉父组件转置
        this.$store.state.SelecttDimension.col = this.arrValue[this.rowVal]
        this.$store.state.SelecttDimension.row = this.arrValue[this.colVal]
        console.log(this.$store.state.SelecttDimension, '非地区数据维度转换=》转置')
        this.$emit('changeSetZZ', true)
        this.$store.state.noAreadimensionState = false
      }
    }
  },
  mounted () {
    console.log('我只醒了')
    console.log(this.$store.state.SelecttDimension, '非地区数据维度转换=》转置')
    this.change3D()
  }
}
</script>
<style lang="scss" scoped>
.dimension {
  width: 100%;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  position: fixed;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  z-index: 10;
  & > .container {
    width: 64.375rem;
    height: 33rem;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    & > .top {
      margin-top: 1rem;
      width: 59.375rem;
      height: 3.875rem;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      border-bottom: 0.125rem solid #bdbdbd;
      font-size: 1.375rem;
      font-weight: normal;
      font-stretch: normal;
      letter-spacing: 0rem;
      color: #333333;
      & > img {
        width: 1.3125rem;
        height: 1.3125rem;
      }
      & > img:hover {
        cursor: pointer;
      }
    }
    & > .main {
      margin-top: 2.6rem;
      width: 59.375rem;
      & > .row {
        width: 59.375rem;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        & > div:nth-child(1) {
          width: 5.25rem;
          height: 3.125rem;
        }
        & > .row_main {
          display: flex;
          flex-direction: row;
          justify-content: flex-start;
          align-items: center;
          & > div {
            width: 5.25rem;
            height: 3.125rem;
            background-color: #a8daf1;
            display: flex;
            flex-direction: row;
            justify-content: center;
            align-items: center;
            color: #fff;
          }
          & > div:nth-child(1) {
            border-radius: 0.1875rem 0 0 0.1875rem;
          }
          & > div:nth-child(3) {
            border-radius: 0 0.1875rem 0.1875rem 0;
          }
          & > .active {
            background-color: #52b6e3;
          }
        }
        & > div:hover {
          cursor: pointer;
        }
      }
      & > .col {
        width: 59.375rem;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: flex-start;
        & > .row_main {
          display: flex;
          flex-direction: column;
          justify-content: flex-start;
          align-items: center;
          & > div {
            width: 5.25rem;
            height: 3.125rem;
            background-color: #a8daf1;
            display: flex;
            flex-direction: row;
            justify-content: center;
            align-items: center;
            color: #fff;
          }
          & > div:nth-child(1) {
            border-radius: 0.1875rem 0 0 0.1875rem;
          }
          & > div:nth-child(3) {
            border-radius: 0 0.1875rem 0.1875rem 0;
          }
          & > .active {
            background-color: #52b6e3;
          }
          & > div:hover {
            cursor: pointer;
          }
        }
        & > .tabel {
          display: flex;
          flex-direction: column;
          justify-content: flex-start;
          align-items: flex-start;
          & > div {
            height: 2.5rem;
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            align-items: center;
            & > div {
              height: 2.5rem;
              width: 13.265rem;
              display: flex;
              flex-direction: row;
              justify-content: center;
              align-items: center;
              border: 1px solid black;
            }
          }
        }
      }
    }
    & > .bottom {
      width: 59.375rem;
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: flex-start;
      & > div:nth-child(1) {
        width: 15.625rem;
        height: 3.1875rem;
        background-color: #52b6e3;
        border-radius: 0.3125rem;
        font-size: 1.25rem;
        font-weight: normal;
        font-stretch: normal;
        letter-spacing: 0rem;
        color: #ffffff;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
      }
      & > div:nth-child(2) {
        width: 15.625rem;
        height: 3.1875rem;
        border: solid 0.125rem #dbdbdb;
        border-radius: 0.3125rem;
        font-size: 1.25rem;
        font-weight: normal;
        font-stretch: normal;
        letter-spacing: 0rem;
        color: #666666;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
      }
      & > div {
        margin: 3rem 1.2rem;
      }
      & > div:hover {
        cursor: pointer;
      }
    }
  }
}
</style>
